#include <54func.h>
int main(int argc,char *argv[])
{
    // ./3_homework_transfer file   -->   用于将一段文本大小写进行转换
    ARGS_CHECK(argc,2);
    int fd = open(argv[1],O_RDWR);
    ERROR_CHECK(fd,-1,"open");

    //截取文件大小
    int ret = ftruncate(fd,4096);
    ERROR_CHECK(ret,-1,"ftruncate");
    //mmap:磁盘内容映射到用户态内存中
    char *p = (char *)mmap(NULL,4096,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
    ERROR_CHECK(p,NULL,"mmap");

    for(int i=0;i<4096;i++)
    {
        if(p[i]>='a' && p[i]<='z'){
            p[i] -=32;
            printf("%c",p[i]);
        }else if(ispunct(p[i]))//将标点符号转换为空格
        {
            p[i] = ' ';
        }
    }
    
    munmap(p,4096);
    close(fd);
    
    return 0;
}
